package org.his.service.impl;

import java.util.List;

import org.his.entity.Patient;
import org.his.mapper.PatientMapper;
import org.his.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PatientServiceImpl implements PatientService{
	@Autowired
	private PatientMapper patientMapper;
	
	public Patient checkPatient(String checkNo) {
		return patientMapper.queryPatientByNo(checkNo);
		
	}

	public int addPatient(Patient addPatient) {
		int count = 0;
		try {
			if (addPatient.getDiagnosticcard() != null && addPatient.getDiagnosticcard() != "") 				
				count = patientMapper.addPatient(addPatient);
		} catch (Exception e) {
			e.printStackTrace();
			count = -1;
		}
		
		return count;
		
	}

	public List<Patient> queryPatientByForm(Patient qPatient) {
		List<Patient> patients =patientMapper.queryPatientByForm(qPatient);
		return patients;
	}

	public int updatePatient(Patient updatePatient) {
		int count = 0;
		 count = patientMapper.updatePatient(updatePatient);
		return count;
	}

}
